package com.ball.dev.controller;


import com.ball.common.dtos.ResponseResult;
import com.ball.dev.entity.po.Personal;
import com.ball.dev.service.IPersonalService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 个人信息表
 * <p>
 * 个人信息表 前端控制器
 * </p>
 *
 * @author lou
 * @since 2023-12-04
 */


@RestController
@RequestMapping("/personal")
@RequiredArgsConstructor
public class PersonalController {
    private final IPersonalService personalService;
   @PostMapping("/add")
    public ResponseResult addPersonal(@RequestBody Personal personal){
        //调用personalService的addPersonal方法，传入personal参数
        return personalService.addPersonal(personal);
    }

   //根据id获取Personal信息
  @GetMapping("/{userid}")
    public ResponseResult getPersonalById(@PathVariable("userid") Long userid){
        //调用personalService的getPersonalById方法根据id获取Personal信息
        return personalService.getPersonalById(userid);
    }

   @PutMapping("/updatePersonal")
    public ResponseResult updatePersonal(@RequestBody Personal personal){
		//调用personalService的updatePersonal方法更新Personal信息
       return  personalService.updatePersonal(personal);
    }



    @GetMapping("/getUserList")
    public ResponseResult getUserList(){

        //调用personalService的getUserList方法获取用户列表
        return personalService.getUserList();
    }

    @PutMapping("/ManageUpdate")
    public ResponseResult ManageUpdate(@RequestBody Personal personal){
        //调用personalService的updatePersonal方法更新Personal信息
        return  personalService.ManageUpdate(personal);
    }

    @GetMapping("/manage")//删除用户
    public ResponseResult deleteUser(@RequestParam("id") String id,@RequestParam("status") Integer status){
        //调用personalService的deleteUser方法删除用户
        return personalService.deleteUser(id,status);
    }

    @GetMapping("/manage/{id}")
    public ResponseResult getPersonalById2(@PathVariable("id") String id){
        //调用personalService的getById方法根据id获取Personal信息
        Personal personal = personalService.getById(id);
        return ResponseResult.okResult(personal);
    }

}
